package com.service.impl;

import com.service.ProductEsService;
import core.entity.es.ProductEs;
import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate;
import org.springframework.data.elasticsearch.core.mapping.IndexCoordinates;
import org.springframework.stereotype.Service;

import static core.Constants.Es.INDEX_NAME;

@Service
public class ProductEsServiceImpl implements ProductEsService {
    private ElasticsearchRestTemplate elasticsearchRestTemplate;

    public ProductEsServiceImpl(ElasticsearchRestTemplate elasticsearchRestTemplate) {
        this.elasticsearchRestTemplate = elasticsearchRestTemplate;
    }

    @Override
    public void insertDoc(ProductEs productEs) {
        elasticsearchRestTemplate.save(productEs, IndexCoordinates.of(INDEX_NAME));
    }
}
